package com.example.administrator.zhongyichou.activity;

import android.content.Intent;
import android.view.KeyEvent;

import com.example.administrator.zhongyichou.base.BaseActivity;
import com.example.administrator.zhongyichou.Bean.BaseEventBean;
import com.example.administrator.zhongyichou.base.MyApplication;
import com.example.administrator.zhongyichou.config.Constants;
import com.example.administrator.zhongyichou.net.protocol.GsonBaseProtocol;
import com.example.administrator.zhongyichou.net.core.HttpLoader;
import com.example.administrator.zhongyichou.R;

/**
 * Created by 何波静 on 2017/8/9.
 */

public class SplashActivity extends BaseActivity {

    @Override
    protected HttpLoader initHttpLoader() {
        return null;
    }


    @Override
    protected void init() {
        MyApplication.getMainThreadHandler().postDelayed(new MyTask(), 2000);
    }

    @Override
    protected void responseData(GsonBaseProtocol mGsonBaseProtocal) {

    }

    @Override
    protected int initContentView() {

        return R.layout.activity_splash;
    }

    @Override
    public boolean onEventBus(BaseEventBean baseEventBean) {

        return false;
    }


    private class MyTask implements Runnable {
        @Override
        public void run() {
            boolean fist_login = MyApplication.getSPValue(Constants.KEY_HAS_LOGIN, true);
            if (fist_login) {
                //进入登录界面
                Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                startActivity(intent);
            } else {
                //进入主界面
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
            }
            finish();
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }
}
